import Polyglot from 'node-polyglot'

export const translations = {
    'en_US': {
        print_the_current_workspace: 'Print the current workspace',
        trigger_parameter_list: 'Trigger parameter list',
        start_triggering_task: 'Start triggering jenkins task {{jenkinsJob}}',
        start_checking_the_results: 'Start checking the results of the jenkins task {{jenkinsJob}} {{jenkinsBuildNumber}}',
        jenkins_task_log_address: 'Jenkins task log address {{jenkinsMaster}}/job/{{jenkinsJob}}/{{jenkinsBuildNumber}}/console',
        current_task_status: 'The current task status is: {{buildResult}}',
        no_valid_command: 'No valid command, ignore current task',
        reminder_jenkins_supports_passwords_and_tokens: 'Reminder: jenkins supports passwords and tokens, but due to the high security policies of later versions, cross site forgery requests are not allowed. It is recommended to use API tokens. For details, please refer to the help documentation: https://help.aliyun.com/document_detail/467984.html',
        currently_build_number: 'The currently triggered task build number is {{jenkinsBuildNumber}}',
        task_log: 'Task log',
        current_task_is_running: 'The current task is running',
        current_task_aborted: 'The current task has been manually aborted in jenkins and has failed',
        current_task_failed: 'The current task failed to run in Jenkins, the current task has failed',
        current_task_success: 'The current task has been successfully executed',
    },
    'zh_CN': {
        print_the_current_workspace: '打印当前工作区',
        trigger_parameter_list: '触发参数列表',
        start_triggering_task: '开始触发Jenkins任务{{jenkinsJob}}的构建',
        start_checking_the_results: '开始检查Jenkins任务{{jenkinsJob}}第{{jenkinsBuildNumber}}次构建的结果',
        jenkins_task_log_address: 'Jenkins 任务日志地址 {{jenkinsMaster}}/job/{{jenkinsJob}}/{{jenkinsBuildNumber}}/console',
        current_task_status: '当前任务状态为：{{buildResult}}',
        no_valid_command: '没有有效的命令，忽略当前任务',
        reminder_jenkins_supports_passwords_and_tokens: '温馨提示：jenkins支持密码和token,但由于高版本的安全策略比较高,不允许进行跨站伪造请求,推荐使用api token,详情请参考帮助文档:https://help.aliyun.com/document_detail/467984.html',
        currently_build_number: '当前触发的流水线任务构建号为{{jenkinsBuildNumber}}',
        task_log: '任务日志',
        current_task_is_running: '当前任务正在运行中',
        current_task_aborted: '当前任务在Jenkins中被手动Aborted，当前任务失败',
        current_task_failed: '当前任务在Jenkins中运行失败，当前任务失败',
        current_task_success: '当前任务运行成功',
    }
}

const locale = process.env['PIPELINE_LOCALE'] === 'zh_CN' ? 'zh_CN' : 'en_US'
export const polyglot = new Polyglot({
    interpolation: {prefix: '{{', suffix: '}}'},
    phrases: translations[locale]
})